package com.pf.config;

import com.pf.interceptor.DecryptFieldInterceptor;
import com.pf.interceptor.ParameterHandlerInterceptor;
import com.pf.interceptor.SqlMonitorInterceptor;
import com.pf.interceptor.StatementHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisInterceptorConfig {

    /**
     * DecryptFieldInterceptorOld 拦截器实现效率比较低下，寻找 @FieldDecrypt 注解的属性 和 解密时递归循环了两次，效率低下，推荐使用 DecryptFieldInterceptor类
     */
//    @Bean
//    public DecryptFieldInterceptorOld decryptFieldInterceptorOld() {
//        return new DecryptFieldInterceptorOld();
//    }

    @Bean
    public SqlMonitorInterceptor sqlMonitorInterceptor(){
        return new SqlMonitorInterceptor();
    }

    /**
     * 推荐这种方式：解密赋值对应程序效率更高
     *
     * @return
     */
    @Bean
    public DecryptFieldInterceptor decryptFieldInterceptor() {
        return new DecryptFieldInterceptor();
    }

    @Bean
    public ParameterHandlerInterceptor parameterHandlerInterceptor() {
        return new ParameterHandlerInterceptor();
    }

    @Bean
    public StatementHandlerInterceptor statementHandlerInterceptor() {
        return new StatementHandlerInterceptor();
    }
}
